#!/bin/bash
for i in 10.149.212.57 10.149.212.58 10.149.212.53 10.149.212.54 10.149.212.51 10.149.212.52 10.149.212.65
do
    echo -n "$i"
    ip r | grep "$i"
    if [[ $? == '0' ]] 
        then 
            echo '这台机器不应该更新openssh'
            exit 1
    else echo 不匹配
    fi
done
version_file='/etc/redhat-release'
if [ -f "$version_file" ]
    then 
        grep 'release 7' "$version_file" && echo "telnet 是否能远程连接本机（y/n）" && read telnet_active
else exit 1
fi
if [[ "$telnet_active" == 'y' ]] 
    then 
        echo '判断通过,开始备份文件并升级'
        cp -a /etc/ssh/ /var/log && 
	cp -a /etc/pam.d/ /var/log && 
        tar xf openssh-9.3p1-1.el7.tar.gz -C /tmp &&
	yum install /tmp/openssh*.rpm && 
	cp -af /var/log/pam.d/sshd /etc/pam.d/sshd && 
	chmod 600 /etc/ssh/ssh_host*_key && 
	systemctl restart sshd
fi

    
